<template>
  <div>
    <Echart
        :options="options"
        id="centreLeft1Chart"
        height="5.35rem"
        width="100%"
    ></Echart>
  </div>
</template>

<script>
import Echart from '@/common/echart'
export default {
  data () {
    return {
      options: {},
    };
  },
  components: {
    Echart,
  },
  props: {
    cdata: {
      type: Object,
      default: () => ({})
    },
  },
  watch: {
    cdata: {
      handler (newData) {
        this.options = {
          title: {
            text: "",
          },
          tooltip: {
            trigger: "axis",
            backgroundColor: "rgba(255,255,255,0.1)",
            borderWidth:0,
            textStyle: {
              color: "#d5d5d5"
            },
            axisPointer: {
              type: "shadow",
              label: {
                show: true,
                backgroundColor: "#7B7DDC"
              }
            }
          },
          legend: {
            data: newData.category,
            textStyle: {
              color: "#B4B4B4"
            },
            top: "0%"
          },
          grid: {
            left: '3%',
            right: '2%',
            bottom: '3%',
            containLabel: true,
            width: "90%",
          },
          xAxis: {
            data: newData.day,
            axisLabel: { interval: 0, rotate: 30, fontSize: 8 },
            axisLine: {
              lineStyle: {
                color: "#B4B4B4"
              }
            },
            axisTick: {
              show: false
            }
          },
          yAxis: [
            {
              type: 'value'
            }
          ],
          series: [
            {
              name: newData.category[0],
              type: 'line',
              stack: '总量',
              data: newData.data[0],
              smooth: false
            },
            {
              name: newData.category[1],
              type: 'line',
              stack: '总量',
              data: newData.data[1],
              smooth: false
            },
            {
              name: newData.category[2],
              type: 'line',
              stack: '总量',
              data: newData.data[2],
              smooth: false
            }
          ],
        }
      },
      immediate: true,
      deep: true
    }
  }
};
</script>
